﻿@model IEnumerable<zuoye.Models.Task>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("添加", "Add1")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.TaskPriority)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Content)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.TaskState)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FinishedTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.uid)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.TaskPriority)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Content)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AddTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TaskState)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FinishedTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.uid)
            </td>
            <td>

                <a href="#" data-del="@item.TaskID">删除</a>
                <a href="@Url.Action("Detail","Default",new {te=item.TaskID })">详情</a>
                <a href="@Url.Action("BianJi","Default",new {te=item.TaskID })">修改</a>
                @*@Html.ActionLink("Edit", "Add1", new { id=item.TaskID }) |
        @Html.ActionLink("Details", "Detail", new { id=item.TaskID }) |
        @Html.ActionLink("Delete", "Delete", new { id=item.TaskID })*@
            </td>
        </tr>
    }

</table>
@section scripts{
    <script type="text/javascript">
        $(function () {
            $("a[data-del]").click(function () {
                var $this = $(this);
                var id = $this.attr("data-del");
                if (!confirm("你确定要删除第" + id + "行吗？？？")) return;
                $.post('@Url.Action("Delete","Default")' ,{ id: id }, function (result) {
                    if (result == true) {
                        location.reload();//刷新整张页面
                        $this.closest("tr").remove();
                        alert("删除成功");
                    }
                })
            })
        })
    </script>
}


